import React, { Component } from 'react'; 
import { connect } from 'react-redux';
import { saveLoginUser, saveLoginPerm } from '../store/store1/action';
import Header1 from '../components/Header1.js';
import Layout1 from '../layouts/Layout1.js';

class Hello1 extends Component {
	// 总数据
	state = {
		// 新增-弹窗开头
		mag: 'h111'
	}
	// 点击1
	searchList1 = () => {
		const { orderSum } = this.props.loginUser;
    	console.log(orderSum);
    	this.props.saveLoginUser('123', 'orderSum');
	}
	// 点击2
	searchList2 = () => {
		const { flag1 } = this.props.loginPerm;
    	console.log(flag1);
    	this.props.saveLoginPerm(!flag1, 'flag1');
	}
	// 渲染函数
    render() {
    	return (
			<div>
				<Layout1>
					<header className="App-header">
						Hello1122
						<Header1></Header1>
						<div>{this.state.mag}</div>
						<span onClick={this.searchList1}>修改store的值1</span>
						<span onClick={this.searchList2}>修改store的值2</span>
					</header>
				</Layout1>
			</div>
		);
    }
};

export default connect(state => ({
	loginUser: state.loginUser,
	loginPerm: state.loginPerm,
}), {
	saveLoginUser, 
	saveLoginPerm,
})(Hello1);
